# -*- coding: utf-8 -*-
"""
@author:  bingyl123@163.com
@version: 1.0.0
@file:    log.py
@time:    2023/2/23 20:00
"""
import logging


def create_logger():
    logger = logging.getLogger("app")
    formatter = logging.Formatter("%(asctime)s[%(levelname)s]: %(message)s", datefmt="%Y-%m-%d %H:%M:%S")

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(formatter)

    file_handler = logging.FileHandler("app.log", encoding="utf8")
    file_handler.setFormatter(formatter)

    logger.setLevel(logging.INFO)
    logger.addHandler(console_handler)
    logger.addHandler(file_handler)
    return logger


